﻿@{
    ViewBag.Title = "TagThis.Org";
}
<script type="text/javascript">
    @*var urlpattern = @FsWeb.Settings.urlPatternregExp*@
</script>
<style>
    form button {
        border: 0px;
    }
</style>
<header>
    <div class="wrap">
        <div class="logo">
            <a ui-sref="index({type: $searchType.selected.type})" class="tag">TagThis.Org</a>
        </div>
        <nav>
            <ul>
                <li>
                    <div class="modal-wrap" ng-controller="addSiteController">
                        <a href="#" id="href-addsite"><i class="icon icon-plus"></i>Добавить сайт</a>
                        <div class="modal modal-add modal-top">
                            <form name="addSiteForm" class="modal-form" ng-class="{error : (!addSiteForm.$valid ) || IsServerError, success: addSiteForm.$valid && !IsServerError }" ng-submit="submit()">
                                @if (User.Identity.IsAuthenticated)
                                {
                                    <input type="text"
                                    ng-blur = "blur()"
                                    ng-focus="titleIsChanged=false"
                                    ng-pattern="@Data.Settings.Settings.urlPatternregExp"
                                    name="url"
                                    ng-model="bookmark.url"
                                    class="input"
                                    placeholder="адрес сайта"
                                    autocomplete="off"
                                        value ="{{bookmark.url | lowercase}}"
                                    required />
                                }
                                else
                                {
                                    <input type="text"
                                    ng-pattern="@Data.Settings.Settings.urlPatternregExp"
                                    name="url"
                                    ng-model="bookmark.url"
                                    class="input"
                                    placeholder="адрес сайта"
                                    autocomplete="off"
                                    required />
                                }
                                <i class="icon icon-tag"></i>
                                <input name="tagList" 
                                    ng-change="GetNewMessge()"
                                    ng-model="bookmark.userTags"
                                    ng-list="@Data.Settings.Settings.separatorRegEx" 
                                    type="text" class="input input-tag" 
                                    placeholder="теги" 
                                    autocomplete="off" 
                                    value=""
                                    ng-required="true" />
                                @* <div class="input input-tag"><ul id="addtags"></ul></div>  можно добавить обертку тегов   *@
                                @if (User.Identity.IsAuthenticated)
                                {
                                    <input name="title" ng-model="bookmark.userTitle" class="input" type="text" placeholder="название" ng-change="titleIsChanged = true" autocomplete="off" />
                                }
                                <div class="status">
                                    <button ng-show="addSiteForm.$valid" class="submit button">добавить</button>
                                    <div class="success">
                                        <span ng-hide="IsRequest">
                                            <span><i class="icon icon-ok"></i>{{OkMessage}}</span>
                                        </span>
                                        <span ng-show="IsRequest">
                                            <i class="loader"></i>Отправка... 
                                        </span>
                                    </div>
                                    <div class="error" ng-init="addSiteForm.tagList.$error.required = true">
                                        <li ng-repeat="e in ErrorMessage" ng-show="IsServerError"><span><i class="icon icon-error"></i>{{ e }}</span></li>
                                        <li ng-show="addSiteForm.url.$dirty && addSiteForm.url.$error.required"><span><i class="icon icon-error"></i>Пожалуйста введите адрес сайта</span></li>
                                        <li ng-show="addSiteForm.url.$dirty && addSiteForm.url.$error.pattern && !addSiteForm.url.$error.required"><span><i class="icon icon-error"></i>Вы ввели не <a src="http://ru.wikipedia.org/wiki/URL">url</a></span></li>
                                        <li ng-show="addSiteForm.tagList.$dirty && addSiteForm.tagList.$error.required"><span><i class="icon icon-error"></i>Надо добавить хотя бы один тег</span></li>
                                    </div>

                                </div>
                            </form>
                        </div>
                    </div>
                </li>
                @if (!User.Identity.IsAuthenticated)
                {
                    <li>
                        <div class="modal-wrap" ng-controller="registrationController">
                            <a href="#">Зарегистрироваться</a>
                            <div class="modal modal-signup modal-top" style="display: none;">
                                <form name="registerForm" class="modal-form" ng-class="{error : (!registerForm.$valid ) || IsServerError, success: registerForm.$valid && !IsServerError }" ng-submit="submit()">
                                    @Html.AntiForgeryToken()
                                    <input name="login" ng-model="user.username" type="text" class="input" placeholder="логин" required />
                                    <input name="password" ng-model="user.password" type="password" ng-minlength="6" class="input" placeholder="пароль" autocomplete="off" required />.
                                            <input name="confirmpassword" password-verify="user.password" ng-model="user.confirmpassword"
                                                type="password" class="input" placeholder="повторите пароль" required />
                                    <div class="status">
                                        <button ng-show="registerForm.$valid" ng-click="submit()" class="submit button">зарегистрироваться</button>

                                        <div class="success">
                                            <span ng-hide="IsRequest"><i class="icon icon-ok"></i>Все ок. {{ OkMessage }}</span>
                                            <span ng-show="IsRequest"><i class="loader"></i>Отправка... </span>
                                        </div>
                                        <div class="error">
                                            <ul>
                                                <li ng-repeat="e in ErrorMessage" ng-show="IsServerError"><i class="icon icon-error"></i>{{ e }}</li>
                                                <li ng-show="registerForm.login.$error.required && registerForm.login.$dirty"><i class="icon icon-error"></i>Введите логин. Смелее, это легко! :) </li>
                                                @*   <li ng-show="registerForm.password.$error.required">Пароль нужен. Без него можете даже не пытаться жить в сети. </li>*@
                                                <li ng-show="registerForm.password.$dirty && registerForm.password.$error.minlength"><i class="icon icon-error"></i>Давайте-ка пароль длиннее. Хотя бы 6 символов. </li>
                                                <li ng-show="registerForm.confirmpassword.$dirty && registerForm.confirmpassword.$error.passwordVerify"><i class="icon icon-error"></i>Всё же пароли в обоих полях должны совпадать. </li>
                                            </ul>
                                        </div>
                                    </div>

                                    <div name="socialFormReg" class="social">
                                        <input type="hidden" name="provider" value="" />
                                        <div class="social-text">Так же вы можете войти используя следующие сайты:</div>
                                        <ul class="social-icons">
                                            <li><a href="#" name="vkontakte" onclick="externalLogin(this.name)"><i class="icon icon-vk"></i></a></li>
                                            <li><a href="#" name="facebook" onclick="externalLogin(this.name)"><i class="icon icon-fb"></i></a></li>
                                            <li><a href="#" name="twitter" onclick="externalLogin(this.name)"><i class="icon icon-tw"></i></a></li>
                                            <li><a href="#" name="google" onclick="externalLogin(this.name)"><i class="icon icon-g"></i></a></li>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </li>
                }
                else
                {
                    <li><a href="#/tags">Мое избранное</a></li>
                    <li><a href="#/manage">@User.Identity.Name</a>
                    </li>
                }
                <li class="slash"></li>
                @if (!User.Identity.IsAuthenticated)
                {
                    <li>
                        <div class="modal-wrap" ng-controller="loginUserContrller">
                            <a href="#" class="">Войти</a>
                            <div class="modal modal-signin modal-top" style="display: none;">
                                <form if="loginForm" name="loginForm" class="modal-form" ng-class="{error : (!loginForm.$valid ) || IsServerError, success: loginForm.$valid && !IsServerError }" ng-submit="submit()">
                                    <input name="login" ng-model="user.username" type="text" class="input" placeholder="логин" required>
                                    <input name="password" ng-model="user.password" type="password" class="input" placeholder="пароль" required>
                                    <div class="status">
                                        <div class="checkbox">
                                            <i class="icon icon-checkbox"></i>запомнить меня
                                                    <input ng-model="user.rememberMe" name="remember_me" type="checkbox">
                                        </div>
                                        <button ng-show="loginForm.$valid" class="submit button">войти</button>
                                        <div class="success">
                                            <span ng-hide="IsRequest"><i class="icon icon-ok"></i>Все ок. {{ OkMessage }}</span>
                                            <span ng-show="IsRequest"><i class="loader"></i>Отправка...</span>
                                        </div>
                                        <div class="error">
                                            <li ng-repeat="e in ErrorMessage" ng-show="IsServerError"><i class="icon icon-error"></i>{{ e }}</li>
                                        </div>
                                    </div>

                                    <div class="social">
                                        <div class="social-text">Так же вы можете войти используя следующие сайты:</div>
                                        <ul class="social-icons">
                                            <li><a href="#" name="vkontakte" onclick="externalLogin(this.name)"><i class="icon icon-vk"></i></a></li>
                                            <li><a href="#" name="facebook" onclick="externalLogin(this.name)"><i class="icon icon-fb"></i></a></li>
                                            <li><a href="#" name="twitter" onclick="externalLogin(this.name)"><i class="icon icon-tw"></i></a></li>
                                            <li><a href="#" name="google" onclick="externalLogin(this.name)"><i class="icon icon-g"></i></a></li>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </li>
                }
                else
                {
                    <li>
                        <form action="/Account/LogOff" id="logoutForm" method="post">
                            @Html.AntiForgeryToken()
                        </form>
                        <a href="#" onclick="document.getElementById('logoutForm').submit()">Выйти</a>
                    </li>
                }
            </ul>
        </nav>
    </div>
</header>
<div ui-view>
    <h1>Загрузка...</h1>
</div>
